package com.example.demo.mapper;

import com.example.demo.entity.Article;
import com.example.demo.entity.ArticleImg;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 文章图片表 Mapper 接口
 * </p>
 *
 * @author Mr.Yang
 * @since 2024-06-03
 */
@Mapper
public interface ArticleImgMapper extends BaseMapper<ArticleImg> {

    /**
     * 根据文章ID查询图片
     * @param articleId
     * @return
     */
    @Select("SELECT * FROM article_img WHERE article_id = #{articleId} AND flag = 1")
    public List<ArticleImg> selectByArticleId(Integer articleId);

    @Insert("INSERT INTO article_img(article_id,img_path,create_time) VALUES(#{articleId},#{imgPath},NOW())")
    public boolean insertArticleImg(ArticleImg articleImg);
    //查询所有图片
    @Select("SELECT * FROM article_img WHERE flag = 1")
    public List<ArticleImg> selectAllImg();

}
